package com.hq.fxh.No5_User.MyModle.Activity.item;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.No5_User.MyModle.AdBannerInfo;
import com.hq.fxh.R;
import com.hq.fxh.Utils.GlideUtils;


/**
 * @author 大圣
 * @ClassName GraphicAdContentItem
 * @Description : 图文广告内容
 * @Created 2015/12/22 0022
 * @Email qwqe601660957@163.com
 */
public class GraphicAdContentItem extends LinearLayout {
    /** 图文广告图片信息 */
    private ImageView ivGraphicPic;
    /** 产品名称 */
    private TextView tvProductName;
    /** 产品描述 */
    private TextView tvProductDes;
    private LinearLayout llGraphicAd;
    private ViewGroup.LayoutParams params;

    //    private AppCompatCheckBox cbPic;
    public GraphicAdContentItem(Context context) {
        super(context);
        inflate(context, R.layout.item_graphic_ad_content, this);
        initView();
    }

    private void initView() {
        ivGraphicPic = (ImageView) findViewById(R.id.ivGraphicPic);
        tvProductName = (TextView) findViewById(R.id.tvProductName);
        tvProductDes = (TextView) findViewById(R.id.tvProductDes);
        llGraphicAd = (LinearLayout)findViewById(R.id.llGraphicAd);
//        cbPic = (AppCompatCheckBox) findViewById(R.id.cbPic);
//        params = llGraphicAd.getLayoutParams();
//        WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
//        int width = wm.getDefaultDisplay().getWidth();
//        params.height = width*250/750;
    }

    /**
     *
     * @param adInfo
     */
    public void showAdInfo(final AdBannerInfo adInfo){
        if(adInfo != null){
            final AdBannerInfo.AdvertDetailBean merchantArticleGraphicModel = adInfo.getAdvert_detail();
            if(merchantArticleGraphicModel != null){
//                final Pic graphicPic = merchantArticleGraphicModel.getPic();
//                if(graphicPic != null){
//                    if(graphicPic.isNative()){
//                        Bitmap bitmap = ImageUtils.bytes2Bimap(Base64.decode(graphicPic.getPicData(), Base64.DEFAULT));
//                        ivGraphicPic.setImageBitmap(bitmap);
//                    }else{
                //圆角图片
                GlideUtils.loadImageView(getContext(), merchantArticleGraphicModel.getPic(), ivGraphicPic);
         //       GlideUtils.loadRoundedImage(getContext(),merchantArticleGraphicModel.getPic(),getContext().getResources().getDimensionPixelSize(R.dimen.size_6),ivGraphicPic);
//                         IImageLoader.getInstance().load(getContext(),ivGraphicPic,merchantArticleGraphicModel.getPic(),new DisplayImageOption(options2));
//                    }

                }
                tvProductName.setText(merchantArticleGraphicModel.getName());
                tvProductDes.setText(merchantArticleGraphicModel.getDes());

            }
        }
    }

